import { MidwayConfig } from '@midwayjs/core';

export default {
  // use for cookie sign key, should change to your own and keep security
  keys: '1753179390320_3133',
  koa: {
    port: 9001,
    // 启用CORS支持
    cors: {
      origin: '*', // 允许所有域名访问，生产环境建议设置具体域名
      allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
      allowHeaders: ['Content-Type', 'Authorization', 'Accept'],
      credentials: false
    },
    // 配置body解析器
    bodyParser: {
      enableTypes: ['json', 'form', 'text'],
      formLimit: '10mb',
      jsonLimit: '10mb',
      textLimit: '10mb'
    }
  },
  // 配置文件上传
  multipart: {
    mode: 'file',
    tmpdir: './uploads/tmp',
    cleanTimeout: 5 * 60 * 1000, // 5分钟清理临时文件
    fileSize: '10mb',
    whitelist: ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp'],
    fileExtensions: ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp']
  },
  // 配置上传组件
  upload: {
    mode: 'file',
    fileSize: '10mb',
    whitelist: ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp']
  }
} as MidwayConfig;
